from flask import Flask # 需要改写Flask的话
# from .app import Flask    # 在/app/app.py中继承改写_Flask


def register_blueprints(app):
    '''
    注册模块
        使用blueprint分块
    '''
    from app.admin import admin
    from app.home import home
    from app.api import api
    app.register_blueprint(home)
    app.register_blueprint(admin, url_prefix='/admin')
    app.register_blueprint(api, url_prefix='/v1')  # 添加版本号

def register_plugin(app):
    '''
    注册插件
        数据库
        redis 
    '''
    # from app.models.base import db
    # db.init_app(app)
    # with app.app_context():
    #     db.create_all()
    pass

def create_app():
    app = Flask(__name__)
    app.config.from_object('app.config.settings')

    register_blueprints(app)
    register_plugin(app)
    return app